/** Copyright 2011 Daniel Tosello, Conal Tuohy
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
<?xml-stylesheet href=" /xforms/xsltforms/xsltforms.xsl" type="text/xsl"?>
<!--
<?xml-stylesheet type="text/css" href="/xforms/css/xforms.css" ?>
<?xml-stylesheet type="text/css" href="/css/CMSS.css" ?> -->
<?xsltforms-options debug="yes" lang="en"?>
<?css-conversion no?>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:xf="http://www.w3.org/2002/xforms"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:my="http://hdl.handle.net/102.100.100/6976"
    my:dummy="">

	<head>
		<title>Edit Project Metadata</title>
<!--
        <style type="text/css">
		@namespace xf url(http://www.w3.org/2002/xforms);
		/* Note that when XSLTForms translates XForms markup into XHTML markup, the structure of the XHTML doesn't */
		/* exactly reflect that of the XForms, so care has to be taken to ensure the CSS rules apply. */
		/* In particular: when e.g. an XForms textarea is converted into an XHTML textarea, the output consists of a set of*/
		/* XHTML spans (one of which has @class="xforms-textarea"), wrapping an XHTML textarea. */
		/* In the output CSS, the "xf|textarea" */
		/* selector is mapped to ".xforms-textarea", which means that the rules associated with that selector will apply */
		/* to the wrapper span, and will be inherited by the inner XHTML textarea only if the XHTML textarea has the */
		/* value "inherit" for those properties, or "100%" in the case of width, etc. */
		textarea.xforms-value {
			width: 100%;
		}
		xf|textarea {
			width: 50em;
		}
		body {
			padding: 1em;
			background-color: #F7F9F5;
		}

		#heading {
			border-bottom: 1px solid #BF0404;

		}

		#content {
			border: 10px solid #C2C6AF;
			padding: 10px;

		}

		.xforms-value {
			width: 25em;
		}

		/* Active components/xforms css */

		.xforms-invalid {
			background-color: #FF0;
		}

		*:disabled {
			visibility: hidden;
		}

		/* Display repeat-items with a dashed border */
		*:repeat-item { border: dashed; }

        </style>
-->
		
		
		<link type="text/css" href="/xforms/css/xforms.css" rel="stylesheet"/>
        <link type="text/css" href="/css/CMSS.css" rel="stylesheet"/>


		<xf:model id="project-metadata-editor-model">
			<xf:instance id="project-metadata" src="project" />
			<xf:instance id="project-template" src="/xforms/project-template.xml"/>
			<xf:bind nodeset="instance('project-metadata')/my:startDate" type="xf:dateTime" />
			<xf:bind nodeset="instance('project-metadata')/my:endDate" type="xf:dateTime" />
			<xf:bind nodeset="instance('project-metadata')/my:email" type="xf:email" />
			<xf:bind nodeset="instance('project-metadata')/my:url" type="xf:anyURI" constraint="(starts-with(.,'http://') or starts-with(.,'https://')) and not(contains(.,' '))" />
			<xf:submission id="save" instance="project-metadata" action="project" method="put" serialization="application/xml" replace="none"/>
			<xf:instance id="handle" src="handle"/>		
		</xf:model>	


	</head>

	<body>
		<div id="heading">
			<img width="215" height="82" src="/xforms/images/latrobe_university.gif" />
			<h1>		
				<xf:output ref="instance('project-metadata')/my:name" />
			</h1>
		</div>
		<div id="body">
			<div id="logos">
				<img style="position: relative" src="/xforms/images/cmss_logo.gif" />
				<img src="/xforms/images/VeRSI.gif" />
			</div>
			
			<!--
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/key" >
				<xf:label>Key</xf:label>
			</xf:input>
			<br/>-->
			
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:name" >
				<xf:label>Name</xf:label>
				<xf:hint>Reference name for the project</xf:hint>
			</xf:input>
			<br/>
			 
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:department" >
				<xf:label>Department</xf:label>
			</xf:input>
			<br />
			
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:institution" >
				<xf:label>Institution</xf:label>
				<xf:hint>Initiating institution or primary point of research</xf:hint>
			</xf:input>
			<br/>
		
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:abbreviatedName" >
				<xf:label>Abbreviated Name</xf:label>
			</xf:input>
			<br />	
	 	
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:url" >
				<xf:label>URL</xf:label>
				<xf:hint>A link to the project homepage, or an appropriate summary page</xf:hint>
			</xf:input>
			<br />
			
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:email" >
				<xf:label>Email</xf:label>
				<xf:hint>Primary email contact for the project</xf:hint>
			</xf:input>
			<br/>

			
<!--
			<xf:repeat nodeset="instance('project-metadata')/otherElectronic"> 
				<h3>Other Electronic <xf:trigger>
								    	<xf:label>Remove</xf:label>
		    							<xf:delete ev:event="DOMActivate" nodeset="." />
								    	</xf:trigger></h3>
				<xf:input ref="./@type" >
			    	<xf:label>Type</xf:label>
			    </xf:input>
				<xf:input ref="." >
			    	<xf:label>Contact</xf:label>
				</xf:input>
			    <xf:trigger>
			    	<xf:label>Remove</xf:label>
		    		<xf:delete ev:event="DOMActivate" nodeset="." />
		    	</xf:trigger>
			</xf:repeat>
				<xf:trigger>
					<xf:label>Add Other Electronic</xf:label>
				    	<xf:insert
				        	ev:event="DOMActivate"
			    	        origin="instance('project-template')/otherElectronic"
			        	    position="after"/>
				</xf:trigger>
			<br />
-->
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:startDate">
				<xf:label>Start Date</xf:label>
				<xf:hint>Project initiation date</xf:hint>
			</xf:input>
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:endDate">
				<xf:label>End Date</xf:label>
				<xf:hint>Project termination date</xf:hint>
			</xf:input>

			<h2>Postal Address:</h2>
			<xf:textarea model="project-metadata-editor-model" ref="instance('project-metadata')/my:postalAddress/my:text" >
				<xf:label>Address</xf:label>
			</xf:textarea><br />
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:postalAddress/my:state" >
				<xf:label>State</xf:label>
			</xf:input>
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:postalAddress/my:postcode"  >
				<xf:label>Postcode</xf:label>
			</xf:input><br />
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:postalAddress/my:country"  >
				<xf:label>Country</xf:label>
			</xf:input><br />
			
			<h2>Street Address:</h2>
			<xf:textarea model="project-metadata-editor-model" ref="instance('project-metadata')/my:streetAddress/my:text"  >
				<xf:label>Address</xf:label>
			</xf:textarea><br />
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:streetAddress/my:state"  >
				<xf:label>State</xf:label>
			</xf:input>
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:streetAddress/my:postcode" >
				<xf:label>Postcode</xf:label>
			</xf:input><br />
			<xf:input model="project-metadata-editor-model" ref="instance('project-metadata')/my:streetAddress/my:country"  >
				<xf:label>Country</xf:label>
			</xf:input><br />

			<xf:repeat nodeset="instance('project-metadata')/my:hasMember">
				<xf:input ref=".">
					<xf:label>Member ID</xf:label>
					<xf:hint>A key reference to a <i>person</i> record. This reference can be found in the <i>key</i> field of the person's record</xf:hint>
				</xf:input> <xf:trigger>
								<xf:label>Remove</xf:label>
								<xf:delete ev:event="DOMActivate" nodeset="."/>
							</xf:trigger>
			</xf:repeat>
				<xf:trigger>
					<xf:label>Add Member</xf:label>
					<xf:insert
						ev:event="DOMActivate"
						origin="instance('project-template')/my:hasMember[1]"
						position="after" />
				</xf:trigger>

			<xf:textarea model="project-metadata-editor-model" ref="instance('project-metadata')/my:briefDescription">	
				<xf:label><h2>Brief Description</h2></xf:label>
				<xf:hint>A summary description of the project and its intended aims</xf:hint>
			</xf:textarea>
			<xf:textarea model="project-metadata-editor-model" ref="instance('project-metadata')/my:fullDescription">	
				<xf:label><h2>Full Description</h2></xf:label>
				<xf:hint>A description of the aims, methodologies and key individuals and roles associated with the project</xf:hint>
			</xf:textarea>
			<xf:repeat nodeset="instance('project-metadata')/my:relatedWebsite">
				<div>
					<h2>Related website <xf:trigger>
										<xf:label>Remove</xf:label>
										<xf:delete ev:event="DOMActivate" nodeset="."/>
									</xf:trigger></h2>
									
					<xf:input ref="my:location">
						<xf:label>URL</xf:label>
					</xf:input>
					<br/>
					<xf:input ref="my:title">
						<xf:label>Title</xf:label>
					</xf:input>
					<br/>
					<xf:input ref="my:notes">
						<xf:label>Notes</xf:label>
					</xf:input>
				</div>
			</xf:repeat>
				<xf:trigger>
					<xf:label>Add Related Website</xf:label>
					<!-- @ev:event is what triggers the insert -->
					<!-- @origin is the location of the content to insert -->
					<!-- @context is the evaluation context -->
					<!-- @nodeset specifies where the inserted content goes (evaluated within @context) -->
					<!-- @at specifies at which node in the nodeset to make the insertion (evaluated within @context) --> 
					<!-- @position says to insert the content before or after the nodeset -->
					<xf:insert
						ev:event="DOMActivate"
						origin="instance('project-template')/my:relatedWebsite[1]"
						position="after"/>

				</xf:trigger>

			<xf:repeat nodeset="instance('project-metadata')/my:relatedPublication">
				<div>
					<h2>Related Publication <xf:trigger>
												<xf:label>Remove</xf:label>
												<xf:delete ev:event="DOMActivate" nodeset="."/>
											</xf:trigger></h2>
									
					<xf:input ref="my:location">
						<xf:label>URL</xf:label>
					</xf:input>
					<br/>
					<xf:input ref="my:title">
						<xf:label>Title</xf:label>
					</xf:input>
					<br/>
					<xf:input ref="my:notes">
						<xf:label>Notes</xf:label>
					</xf:input>
				</div>
			</xf:repeat>
				<xf:trigger>
					<xf:label>Add Related Publication</xf:label>
					<!-- @ev:event is what triggers the insert -->
					<!-- @origin is the location of the content to insert -->
					<!-- @context is the evaluation context -->
					<!-- @nodeset specifies where the inserted content goes (evaluated within @context) -->
					<!-- @at specifies at which node in the nodeset to make the insertion (evaluated within @context) --> 
					<!-- @position says to insert the content before or after the nodeset -->
					<xf:insert
						ev:event="DOMActivate"
						origin="instance('project-template')/my:relatedPublication[1]"
						position="after"/>

				</xf:trigger>
			
		</div>
			<xf:trigger>
				<xf:label>Save</xf:label>
				<!-- send data to server (invoking xf:submission[@id='save']) when button pressed (=DOMActivate) -->
				<xf:send ev:event="DOMActivate" submission="save"/>
			</xf:trigger>
			<!-- link to the record by its handle (persistent identifier) - loads the canonical page for the record -->
			<xf:trigger appearance="minimal">
				<xf:label>View this record in the repository</xf:label>
				<xf:action ev:event="DOMActivate">
					<xf:load>
						<xf:resource value="concat('http://hdl.handle.net/', instance('handle')//identifier/@handle)" />
					</xf:load>
				</xf:action>
			</xf:trigger>		
	</body>

</html>		                                                                                                            
